--[[/**
-- * 
* 莉莉技能2 被动buff
 * 当莉莉的血量少于70%/50%/30%时，召唤一团草丛躲进去，持续2秒，期间恢复自身50%攻击力的血量，且无法被锁定攻击，技能CD时间15秒。（一场战斗中最多使用3次该技能）
 */
-- *
-- */]]

---@class BuffEffect175100 : BaseBuffEffect
BuffEffect175100 = ClientFight.CreateClass("BuffEffect175100", ClientFight.BaseBuffEffect)
local t = BuffEffect175100
t.EFFECT_PARAM_BuffEffect175100 = "EFFECT_PARAM_BuffEffect175100";
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local fighter = buff.target;
    if (fighter:isDie()) then
        return IBuffEffect.FAIL;
    end
    local nowHp = fighter.hp;
    local maxHp = FighterAttributeManager.getFightAttr(fighter, FighterAttributeEnum.HP);
    local fightHpPercent = (nowHp * 1 / maxHp * Global.TEN_THOUSANDTH);

    local effectVal = buff.buffBean.f_BuffEffectValue;
    local hpPecent1 = effectVal[1]; -- 70%
    local hpPecent2 = effectVal[3]; -- 50%
    local hpPecent3 = effectVal[5]; -- 30%

    local buffId1 = effectVal[2];
    local buffId2 = effectVal[4];
    local buffId3 = effectVal[6];

    if (fightHpPercent > hpPecent1) then
        return IBuffEffect.FAIL;
    end
    local triggerBuff = buff.effectParams[t.EFFECT_PARAM_BuffEffect175100] or {};
    buff.effectParams[t.EFFECT_PARAM_BuffEffect175100] = triggerBuff;
    if (fightHpPercent <= hpPecent1) then
        if (not table.contains(triggerBuff, hpPecent1)) then
            triggerBuff.add(hpPecent1);
            --buffManager.addBuff(fight, buff.getSkill(), fighter, fighter, false, buffId1, 1, parameters);
            ClientFight.BaseBuffEffect.triggerSkill(self, fight, fighter, fighter, buffId1);
            SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]莉莉技能2被动触发 %s的buff%s,当前血量百分比%s",
                    fight.frame, fighter.fighterId, buff.modelId, fightHpPercent));
            return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

        end
    end
    if (fightHpPercent <= hpPecent2) then
        if (not table.contains(triggerBuff, hpPecent2)) then
            triggerBuff.add(hpPecent2);
            --buffManager.addBuff(fight, buff.getSkill(), fighter, fighter, false, buffId2, 1, parameters);
            ClientFight.BaseBuffEffect.triggerSkill(self,fight, fighter, fighter, buffId2);
            SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]莉莉技能2被动触发 %s的buff%s,当前血量百分比%s",
                    fight.frame, fighter.fighterId, buff.modelId, fightHpPercent));
            return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

        end
    end
    if (fightHpPercent <= hpPecent3) then
        if (not table.contains(triggerBuff, hpPecent3)) then
            triggerBuff.add(hpPecent3);
            --				buffManager.addBuff(fight, buff.getSkill(), fighter, fighter, false, buffId3, 1, parameters);
            ClientFight.BaseBuffEffect.triggerSkill(self,fight, fighter, fighter, buffId3);
            SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]莉莉技能2被动触发 %s的buff%s,当前血量百分比%s",
                    fight.frame, fighter.fighterId, buff.modelId, fightHpPercent));
            return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

        end
    end
    return IBuffEffect.FAIL;
end

t.New()